package com.juc.callable.callable1;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Run {

	/**
	 * get()方法有阻塞特性
	 * @param args
	 * @throws InterruptedException
	 * @throws ExecutionException
	 */
	public static void main(String[] args) throws InterruptedException, ExecutionException {
		MyCallable myCallable = new MyCallable(100);
		ThreadPoolExecutor executor = new ThreadPoolExecutor(2, 3, 5L, TimeUnit.SECONDS, new LinkedBlockingDeque<Runnable>());
		Future<String> future = executor.submit(myCallable);
		System.out.println("main A " + System.currentTimeMillis());
		System.out.println(future.get());
		System.out.println("main B " + System.currentTimeMillis());

	}
}
